package com.twu.biblioteca;

import java.io.PrintStream;
import java.util.ArrayList;

/**
 * Created by IntelliJ IDEA.
 * User: anubhav
 * Date: 1/3/14
 * Time: 7:50 PM
 * To change this template use File | Settings | File Templates.
 */
public class InputParser {

    private InputSeeker input;
    private MenuGenerator menu;
    private PrintStream out;


    public InputParser(InputSeeker in, MenuGenerator menu, PrintStream out) {
        this.input = in;
        this.menu = menu;
        this.out = out;
    }

    public void parse() {

        int key = input.takeIntInput();
        if (menu.isCorrectInput(key)) {
            Action choosedAction = menu.getAction(key);
            choosedAction.executeAction();
        } else {
            out.println("Please enter correct option:");
            parse();
        }
        menu.generateMenu();
        parse();

    }


}
